﻿using ReflectionStudio.Core.Events;
using System;
using System.ComponentModel;
using System.Data;
using System.Windows;
using WPFExcelReport.Helpers;
namespace WPFExcelReport
{
    public partial class TWFUSER
    { 
        public TWFUSER()
        {
            if (DesignerProperties.GetIsInDesignMode(this))
                return;
            MV = new VICC_WFEVENTS();
            this.DataContext = MV;
            try
            {
                InitializeComponent();

            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }
        public override void QueryCommand(object sender, RoutedEventArgs e)
        {
            try
            {
                dwData = TBMain.NewRow();
                dwData["MANDANT"] = app.Mandant;
                dwData["CONTROL"] = CONTROL.PadRight(3);
                dwData["WFEUSER"] = CUSER;
                SResult = TMV.QWF0501(dwData);
                MergeData(SResult, false, true);
            }
            catch (Exception ex)
            {
                Tracer.Error(ex.StackTrace, ex);
            }
        }

        public override void EditCommand(object sender, RoutedEventArgs e)
        {
            if (dwMaster == null)
                return;
            string WFEHANDLER = dwMaster["WFEHANDLER"].ToString();
            string WFEUSER = dwMaster["WFEUSER"].ToString();
            string WFEVENTS = dwMaster["WFEVENTS"].ToString();
            string ORDTYPE = dwMaster["ORDTYPE"].ToString();
            string KRS = dwMaster["KRS"].ToString();
            string LFD = dwMaster["LFD"].ToString();
            string ARTTYPE = dwMaster["ARTTYPE"].ToString();
            string ARTICLE = dwMaster["ARTICLE"].ToString();
            string COLOR = dwMaster["COLOR"].ToString();
            MessageInfo msg = new MessageInfo(MessageEventType.Info, WFEHANDLER, "WORKFLOW", dwMaster["ROWNID"].ToString());
            EventDispatcher.Instance.RaiseMessage(msg);
            IsWFFixed = true;
        }
    }
}
